<template>
  <div>
    <div style="width:30%">
      <h3>考试计划审核</h3>
      <Divider style="height: 2px;margin:15px 0;display: inline-block;" />
    </div>
    <div style="width:80%">
      <h4 style="float: left">审核信息填写</h4>
      <Button id="b1" @click="exit()">退出</Button>
      <Divider style="height: 2px;margin:15px 0;display: inline-block;" />
      <br><br><br><b id="text" style="font-size: 1rem;"></b><br><br><br><br>
    </div>
    <Form style="width: 60%;" ref="formExamination" :model="formExamination" :label-width="120">
      <FormItem label="考试计划审批状态" prop="epaPlanapprosta">
        <Select v-model="formExamination.epaPlanapprosta" clearable style="width:200px">
          <Option v-for="item in ExamTypeList" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
      </FormItem>
      <FormItem label="计划科审批意见" prop="epaPlandeptopi">
        <Input v-model="formExamination.epaPlandeptopi"></Input>
      </FormItem>
      <FormItem label="学历处确认意见" prop="epaEdudeptopi">
        <Input v-model="formExamination.epaEdudeptopi"></Input>
      </FormItem>
      <FormItem label="领导审核意见" prop="epaSuperioropi">
        <Input v-model="formExamination.epaSuperioropi"></Input>
      </FormItem>
      <FormItem>
        <Button type="primary" @click="handleSubmit('formExamination')">提交审核</Button>
      </FormItem>
    </Form>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        formExamination: {
          epaPlanapprosta: '',
          epaPlandeptopi: '',
          epaEdudeptopi: '',
          epaSuperioropi: ''
        },
        ExamTypeList: [{
            value: '计划科提交',
            label: '计划科提交'
          },
          {
            value: '学历处确认',
            label: '学历处确认'
          },
          {
            value: '领导审核',
            label: '领导审核'
          },
          {
            value: '计划发布启用',
            label: '计划发布启用'
          }
        ],
        esId: '',
        ExaminationList: [],
        Opinion: []
      }
    },
    created() {
      // this.$axios.get(this.$host + '/examination/management/allMV_ID?pageNum=1&&pageSize=1000').then(res => {
      //   this.MvIdList = res.data.data.list
      // })
      this.getParams()
      this.$axios.get(this.$host + '/examination/management/allExamsession?pageNum=1&&pageSize=100').then(res => {
        this.ExaminationList = res.data.data.list
        this.$axios.get(this.$host + '/examination/plan/allExamPlan?pageNum=1&&pageSize=100').then(res => {
          this.Opinion = res.data.data.list
        })
        document.getElementById("text").innerHTML = "考次编码：" + this.esId
      })
    },
    watch: {
      '$route': 'getParams'
    },
    methods: {
      getParams() {
        this.esId = this.$route.query.esId
      },
      handleSubmit(name) {
        this.$refs[name].validate((valid) => {
          if (valid) {
            this.$axios.post(this.$host + '/examination/plan/reviewExamPlan', {
              esId: this.esId,
              epaPlanapprosta: this.formExamination.epaPlanapprosta,
              epaPlandeptopi: this.formExamination.epaPlandeptopi,
              epaEdudeptopi: this.formExamination.epaEdudeptopi,
              epaSuperioropi: this.formExamination.epaSuperioropi
            }).then(res => {
              console.log(res)
              if (res.data.message == '审批专业计划成功') {
                this.$Message.success('提交审核成功!');
                if (this.formExamination.epaPlanapprosta == '计划发布启用') {
                  this.$axios.put(this.$host + '/examination/plan/examSessionMessage', {
                    esId: this.esId,
                    esPlanstate: 0
                  })
                }
                this.$router.push({
                  name: 'ExamSessionWithoutCourse'
                })
              } else {
                this.$Message.error('没有修改原本的审核意见!');
              }
            })
          }
        })
      },
      exit() {
        this.$router.push({
          name: 'ExamSessionWithoutCourse'
        })
      }
    }
  }
</script>

<style scoped>
  h3 {
    font-size: 1.75rem;
    float: left;
  }

  #b1 {
    float: right;
    background-color: burlywood;
  }

  #b2 {
    background-color: cadetblue;
  }
</style>
